﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Demo.Classroom
{
    public partial class DemoSimpleBinding : Form
    {
        private HocVien hocvien = new HocVien();

        public DemoSimpleBinding()
        {
            InitializeComponent();

            Binding nameBinding = new Binding("Text", hocvien, "Name");
            Binding scorebinding = new Binding("Text", hocvien, "Score");
            nameText.DataBindings.Add(nameBinding);
            scoreText.DataBindings.Add(scorebinding);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            messageLabel.Text = hocvien.Name + " - " + hocvien.Score.ToString();
        }

        private void updateButton_Click(object sender, EventArgs e)
        {
            // Thay đổi giá trị Name của object hocvien
            hocvien.Name = hocvien.Name + "_";
            hocvien.Score += 1;
        }
    }
}
